<include file="Public:header"/>
<style>
#ad_pic img{max-width:100px;}
</style>
<form method="post" action="__URL__/save_sort">
<table bordercolor="#DDDFFF" border="1" width="100%" style="border-collapse: collapse" cellpadding="3">
	<tr height="17" align="center">
	    <td class="title" width="80">排序</td>
		<td class="title" width="80">广告类型</td>
		<td class="title" width="150">内容</td>
		<td class="title" width="200">链接</td>
		<td class="title" width="110">添加时间</td>
		<td class="title" width="110">失效时间</td>
		<td class="title" width="40">显示</td>
		<td class="title" width="40">删除</td>
		<td class="title">　</td>
	</tr>
<volist name="adlist" id="adlist">
	<tr height="20" bgcolor="#F1F5FA" class="cat_list">
	    <td width="80" align="center">
		    <input type="text" name="adid[]" value="{$adlist.ad_id}" style="display:none">
			<input type="text" name="sorting[]" size="4" value="{$adlist.sorting}">
		</td>
<!--根据广告类型显示-->
<switch name="adlist.type">
    <case value="1">
		<td width="80" align="center">文字</td>
		<td width="150">{$adlist.content}</td>
		<td width="200">无</td>
	</case>
	<case value="2">
		<td width="80" align="center">图片</td>
		<td width="150" align="center" id="ad_pic"><img src="__APP__/{$adlist.file}" height="50" onmouseover="get_pic('{$adlist.file}')" onmouseout="hid_pic()"></td>
		<td width="200"><input type="text" name="url[]" value="{$adlist.path_url}" size="30"></td>
	</case>
	<case value="3">
		<td width="80" align="center">flash</td>
		<td width="150">{$adlist.place_name}</td>
		<td width="200"><input type="text" name="url[]" value="{$adlist.path_url}" size="30"></td>
	</case>
	<case value="4">
		<td width="80" align="center">代码</td>
		<td width="150">{$adlist.place_name}</td>
		<td width="200">无</td>
	</case>
</switch>
		<td width="110">{$adlist.add_time|date="Y/m/d H:i",###}</td>
		<td width="110">{$adlist.end_time|date="Y/m/d H:i",###}</td>
		<td width="40" align="center" id="is_show">
<if condition="$adlist.is_show eq 'true'">
	    <img alt="显示中" src="__APP__/statics/infosuccess.gif" height="15" onclick="to_hidden({$adlist.ad_id})"/>
<else/>
        <img alt="不显示" src="__APP__/statics/infoerror.gif" height="15" onclick="to_show({$adlist.ad_id})"/>
</if>
		</td>
		<td width="40" align="center"><a href="javascript:;" onclick="deletes({$adlist.ad_id})"><img alt="删除" src="__APP__/statics/icons/icon_delete.gif"></a></td>
		<td></td>
	</tr>
</volist>
</table>
<br></br>
<div id="bigpic" style="position:fixed;display:none;top:0px"></div>
<div id="save"><input type="submit" style="padding:2px" value="保存更改"></div>
</form>
<script>
function deletes(t){
    var gid=t;
	if(confirm('你确认删除此广告吗？')) {
       $.ajax({
	       type:"GET",
		   url:"__URL__/remove",
		   dataType:"json",
		   data:{"ad_id":gid},
		   success:function(data){
               if(data=='1'){
				   jSuccess("<strong>删除成功！</strong>",{TimeShown : 500,VerticalPosition : 'center',HorizontalPosition : 'center',onClosed:function(){location.reload();}})
			  }else{
			      jError("<strong>删除失败!请重试</strong>",{VerticalPosition : 'center',HorizontalPosition : 'center'});
			 }
		   }
	   })

	}
}

function to_hidden(t){
    $.ajax({
	       type:"GET",
		   url:"__URL__/change_show",
		   dataType:"html",
		   data:{"action":"hidden","ad_id":t},
		   success:function(data){
		   jSuccess("<strong>更改成功！</strong>",{TimeShown : 500,VerticalPosition : 'center',HorizontalPosition : 'center',onClosed:function(){location.reload();}})
		   }
	})
}

function to_show(t){
    $.ajax({
	       type:"GET",
		   url:"__URL__/change_show",
		   dataType:"html",
		   data:{"action":"show","ad_id":t},
		   success:function(data){
		   jSuccess("<strong>更改成功！</strong>",{TimeShown : 500,VerticalPosition : 'center',HorizontalPosition : 'center',onClosed:function(){location.reload();}})
		   }
	})
}

function get_pic(t){
$("#bigpic").css("display","block");
var pic="<img src='__APP__/"+t+"'>";
$("#bigpic").html(pic);
}

function hid_pic(){
$("#bigpic").css("display","none");
}
</script>
<script src="__APP__/statics/webox/webox.js"></script>
<link href="__APP__/statics/webox/jquery-webox.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
function add(){
		$.webox({
		    scroll:'no',
			height:465,
			width:950,
			bgvisibel:true,
			title:'添加广告位',
			iframe:'__URL__/add/'+Math.random
		});
}
function edit(t){
       var gid=t;
		$.webox({
		    scroll:'no',
			height:465,
			width:950,
			bgvisibel:true,
			title:'修改全局变量',
			iframe:'__URL__/edit/?gid='+gid
		});
}
</script>
